package lumis.portal.htmlevaluation;

import org.w3c.tidy.TidyMessage;

/**
 * Representation of a Message created by Tidy API.
 * This 
 * 
 *
 * @version $Revision: 13093 $ $Date: 2011-05-28 18:40:18 -0300 (Sat, 28 May 2011) $
 * @since 6.0.0
 */
public class HtmlEvaluationMessage
{
	private int errorCode;
	private int line;
	private int column;
	private Level level;
	private String message;

	/**
	 * Level of the Message.
	 * 
	 * @version $Revision: 13093 $ $Date: 2011-05-28 18:40:18 -0300 (Sat, 28 May 2011) $
	 * @since 6.0.0
	 */
	public static enum Level
	{
		INFO,WARNING,ERROR,SUMMARY;
	}
	
	/**
	 * Constructor.
	 * @param tidyMessage a Tidy Message Object.
	 * @since 6.0.0
	 */
	public HtmlEvaluationMessage(TidyMessage tidyMessage)
	{
		this(tidyMessage.getErrorCode(), tidyMessage.getLine(), tidyMessage.getColumn(), Level.valueOf(tidyMessage.getLevel().toString()), tidyMessage.getMessage());
	}
	
	/**
	 * Constructor.
	 * @param errorCode Error code.
	 * @param line line where was found the problem.
	 * @param column column where was found the problem.
	 * @param level level of the problem.
	 * @param message Message.
	 * @since 6.0.0
	 */
	public HtmlEvaluationMessage(int errorCode, int line, int column, HtmlEvaluationMessage.Level level, String message)
	{
		this.setErrorCode(errorCode);
		this.setLine(line);
		this.setColumn(column);
		this.setLevel(level);
		this.setMessage(message);
	}

	/**
	 * Sets the errorCode.
	 * @param errorCode the errorCode value to set.
	 * @since 6.0.0
	 */
	public void setErrorCode(int errorCode)
	{
		this.errorCode = errorCode;
	}

	/**
	 * Returns the errorCode.
	 * @return the errorCode
	 * @since 6.0.0
	 */
	public int getErrorCode()
	{
		return errorCode;
	}

	/**
	 * Sets the line.
	 * @param line the line value to set.
	 * @since 6.0.0
	 */
	public void setLine(int line)
	{
		this.line = line;
	}

	/**
	 * Returns the line.
	 * @return the line
	 * @since 6.0.0
	 */
	public int getLine()
	{
		return line;
	}

	/**
	 * Sets the column.
	 * @param column the column value to set.
	 * @since 6.0.0
	 */
	public void setColumn(int column)
	{
		this.column = column;
	}

	/**
	 * Returns the column.
	 * @return the column
	 * @since 6.0.0
	 */
	public int getColumn()
	{
		return column;
	}

	/**
	 * Sets the level.
	 * @param level the level value to set.
	 * @since 6.0.0
	 */
	public void setLevel(Level level)
	{
		this.level = level;
	}

	/**
	 * Returns the level.
	 * @return the level
	 * @since 6.0.0
	 */
	public Level getLevel()
	{
		return level;
	}

	/**
	 * Sets the message.
	 * @param message the message value to set.
	 * @since 6.0.0
	 */
	public void setMessage(String message)
	{
		this.message = message;
	}

	/**
	 * Returns the message.
	 * @return the message
	 * @since 6.0.0
	 */
	public String getMessage()
	{
		return message;
	}
	
	@Override
	public String toString()
	{
		return "line " + getLine()+ " column " + getColumn() +
				" - " + getLevel().toString() + ": " + getMessage();
	}
}